<template>
  <!-- 导航 -->
  <div class="head-nav">
    <div class="head-nav-content" :class="{ bigWidth: bigWidth }">
      <!-- logo -->
      <div class="nav-left">
        <div class="logo" @click="tab(2)">
          <img src="~/assets/img/logo_text.svg" alt="" />
        </div>
        <!-- 导航内容 -->
        <div class="nav-text">
          <span
            @click="tab(1)"
            class="download"
            :class="{ activeed: downLoadActived }"
            >{{ $t('Download_APP') }}</span
          >
          <span
            @click="tab(2)"
            class="channel"
            :class="{ activeed: !downLoadActived }"
            >{{ $t('Info_channel') }}</span
          >
        </div>
      </div>
      <!-- 右边按钮 -->
      <div class="nav-right">
        <div
          class="nav-tip"
          @mouseenter="showTip = true"
          @mouseleave="showTip = false"
        >
          <span class="tip-title">{{ $t('Discover_get_reward') }}</span>
          <div class="tip-box" v-show="showTip">
            <h4>
              <span>{{ $t('if_News_discover_accepted_reward_$5-100') }}</span
              ><img src="~/assets/img/dollar.svg" alt="" />
            </h4>
            <p>
              1、{{ $t('Phone_discover') }}：0966809063<span
                class="copy"
                v-clipboard:copy="phone"
                v-clipboard:success="onCopy"
                v-clipboard:error="onError"
                ><img src="~/assets/img/copy.svg"
              /></span>
            </p>
            <p>
              2、{{ $t('Wechat_discover') }}：jj966809063<span
                class="copy"
                v-clipboard:copy="wechat"
                v-clipboard:success="onCopy"
                v-clipboard:error="onError"
                ><img src="~/assets/img/copy.svg"
              /></span>
            </p>
            <p class="noneborder" v-if="$i18n.locale === 'zh'">
              3、点击<span @click="tab(1)" class="blue-text">下载APP</span
              >，在APP内进行爆料
            </p>
            <p class="noneborder" v-if="$i18n.locale === 'km'">
              3、ចុច<span @click="tab(1)" class="blue-text">ទាញយក APP</span
              >ផ្តល់ព័ត៌មានតាមAPP
            </p>
          </div>
        </div>
        <div class="changeLan" @click="changeLan" v-if="!hideLan">
          <span v-if="$i18n.locale === 'zh'">
            ភាសាខ្មែរ<img src="~/assets/img/language_kh.svg" alt="" />
          </span>
          <span v-else>
            中文<img src="~/assets/img/language_cn.svg" alt="" />
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showTip: false, //显示tip
      phone: '0966809063',
      wechat: 'jj966809063'
    };
  },
  props: {
    hideLan: {
      default: false
    },
    bigWidth: {
      default: false
    },
    downLoadActived: {
      default: false
    }
  },
  created() {},
  methods: {
    /* 跳转 */
    tab(data) {
      if (data == 1) {
        let routeUrl = this.$router.resolve({
          path: this.$route.params.lang
            ? '/' + this.$route.params.lang + '/pc/download'
            : '/pc/download',
          query: ''
        });
        window.open(routeUrl.href, '_blank');
      } else if (data == 2) {
        let routeUrl = this.$router.resolve({
          path: this.$route.params.lang
            ? '/' + this.$route.params.lang + '/pc'
            : '/pc',
          query: ''
        });
        window.open(routeUrl.href, '_blank');
      }
    },
    onCopy() {
      this.$toast(this.$t('Copy_successfully'));
    },
    onError() {
      this.$toast(this.$t('Copy_failed_try_again'));
    },
    changeLan() {
      let routerData = '';
      if (this.$route.params.lang === undefined) {
        routerData = '/km' + this.$route.fullPath;
      } else if (this.$route.params.lang == 'zh') {
        routerData = this.$route.fullPath.replace(/zh/, 'km');
      } else {
        routerData = this.$route.fullPath.replace(/km/, 'zh');
      }
      this.$router.push({
        path: routerData
      });
    }
  }
};
</script>

<style scoped lang="scss">
/* 导航 */
.head-nav {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  z-index: 999;
  height: 80px;
  width: 100%;
  background: #ffffff;
  box-shadow: 0px 1px 6px 0px rgba(12, 12, 28, 0.08);
  .head-nav-content {
    width: 760px;
    margin: 0 auto;
    padding: 22px 0;
    display: flex;
    justify-content: space-between;
    height: 36px;
    line-height: 36px;
    font-size: 14px;
    .nav-left {
      .logo {
        float: left;
        margin: 0 62px 0 0;
        img {
          width: 104px;
          height: 36px;
        }
      }
      .nav-text {
        float: left;
        .download {
          cursor: pointer;
          color: rgba(12, 12, 28, 0.7);
          font-size: 14px;
          margin: 0 25px 0 0;
          &:hover {
            color: rgba(12, 12, 28, 1);
          }
        }
        .channel {
          cursor: pointer;
          font-size: 14px;
          color: rgba(12, 12, 28, 0.7);
          &:hover {
            color: rgba(12, 12, 28, 1);
          }
        }
        .activeed {
          font-weight: bold;
          position: relative;
          font-size: 16px;
          color: #0c0c1c;
        }
        .activeed::after {
          display: block;
          content: '';
          height: 4px;
          width: 24px;
          position: absolute;
          bottom: -7px;
          left: 50%;
          transform: translateX(-50%);
          background: rgba(250, 70, 70, 1);
          border-radius: 4px;
        }
      }
    }
    .nav-right {
      color: rgba(12, 12, 28, 0.7);
      .nav-tip {
        &:hover .tip-title {
          color: rgba(12, 12, 28, 1);
        }
        float: left;
        margin: 0 24px 0 0;
        position: relative;
        .tip-title {
          cursor: pointer;
        }
        .tip-box {
          h4 {
            font-size: 16px;
            color: #0c0c1c;
            height: 50px;
            overflow: hidden;
            line-height: 50px;
            span {
              font-weight: bold;
              float: left;
            }
            img {
              float: left;
              margin: 12px 0 0 6px;
              width: 24px;
            }
          }
          p {
            font-size: 14px;
            height: 50px;
            line-height: 50px;
            border-bottom: 1px solid #eceff6;
            .copy {
              float: right;
              height: 100%;
              width: 20px;
              cursor: pointer;
              img {
                float: right;
                margin: 17px 0 0 0;
                width: 16px;
              }
            }
          }
          position: absolute;
          top: 40px;
          right: -80px;
          z-index: 99;
          padding: 0 16px;
          box-sizing: border-box;
          width: 300px;
          height: 200px;
          background: #ffffff;
          box-shadow: 0px 0px 4px 0px rgba(12, 12, 28, 0.16);
          border-radius: 5px;
          &::after {
            display: block;
            content: '';
            width: 16px;
            height: 8px;
            background: url('~assets/img/icon_arrow.png') no-repeat center
              center;
            position: absolute;
            top: -8px;
            right: 100px;
            z-index: 99;
          }
        }
      }
      .changeLan {
        display: inline-block;
        cursor: pointer;
        span {
          color: rgba(12, 12, 28, 0.7);
        }
        span:hover {
          color: rgba(12, 12, 28, 1);
        }
        img {
          margin: 0 0 0 4px;
          display: inline-block;
          width: 24px;
          height: 24px;
        }
      }
    }
  }
  .bigWidth {
    width: 960px;
  }
}
/* none border */
.noneborder {
  border: none !important;
}
/* 蓝色 */
.blue-text {
  color: #1a88ee;
  cursor: pointer;
  &:hover {
    text-decoration: underline;
  }
}
</style>
